<?php

require_once 'Pipes/Model/Mapper.php';

class PipesCore_Models_Mappers_TagMapper extends Pipes_Model_Mapper 
{
    /**
     *
     * Handle instantiation
     *
     * In addition to object setup, insure that the DB table exists and if not
     * create it
     *
     */
    public function __construct(PipesImpl_Config $config, PipesImpl_Storage $storage) {
        parent::__construct($config, $storage);

        $exists = $this->_config->pdo->query('SELECT * FROM tags WHERE 1 LIMIT 1');
        if ($exists === false) {
            var_dump($this->_config->pdo->query("
                CREATE TABLE tags(
                    tag_id INT(11) NOT NULL,
                    name VARCHAR(255) NOT NULL,
                    PRIMARY KEY(tag_id)
                )"
            ));
        }
    }

}

